#include "gw_manager.h"




int gw_write_coil(int reg_addr, uint8_t data){
    switch (reg_addr)
    {
    case 33:
        return DO1_switch(data);
        break;
    case 34:
        return DO2_switch(data);
        break;
    default:
        break;
    }
    return -1;
}

int gw_write_coils(int reg_addr, int n, uint8_t *data){
    return 0;
}

int gw_write_register(int reg_addr, uint16_t data){
    return 0;
}

int gw_write_registers(int reg_addr, int n, uint16_t *data){
    return 0;
}

int gw_read_coil(int reg_addr, uint8_t &data){
    int ret = -1;
    switch (reg_addr)
    {
    case 1:
        ret = DI1_get_state();
        break;
    case 2:
        ret = DI2_get_state();
        break;
    case 33:
        ret = DO1_get_state();
        break;
    case 34:
        ret = DO2_get_state();
        break;
    default:
        return -1;
        break;
    }
    if(-1 == ret){
        return -1;
    }
    data = (uint8_t)ret;
    return 0;
}

int gw_read_coils(int reg_addr, int n, uint8_t *data){
    return 0;
}

int gw_read_register(int reg_addr, uint16_t &data){
    return 0;
}

int gw_read_registers(int reg_addr, int n, uint16_t *data){
    return 0;
}